package com.example.yunifangdemo;

import android.support.annotation.IdRes;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class MainActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener{

    private FrameLayout main_fl;
    private RadioGroup mainn_rg;
    private RadioButton main_rb_home;
    private RadioButton main_rb_classify;
    private RadioButton main_rb_community;
    private RadioButton main_rb_shopping;
    private RadioButton main_rb_user;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        main_fl = (FrameLayout) findViewById(R.id.main_fl);
        mainn_rg = (RadioGroup) findViewById(R.id.main_rg);
        main_rb_home = (RadioButton) findViewById(R.id.main_rb_home);
        main_rb_classify = (RadioButton) findViewById(R.id.main_rb_classify);
        main_rb_community = (RadioButton) findViewById(R.id.main_rb_community);
        main_rb_shopping = (RadioButton) findViewById(R.id.main_rb_shopping);
        main_rb_user = (RadioButton) findViewById(R.id.main_rb_user);

        mainn_rg.setOnCheckedChangeListener(this);
        main_rb_home.setChecked(true);
    }

    @Override
    public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {
        switch (i){
            case R.id.main_rb_home:
                main_rb_home.setChecked(true);
                break;
            case R.id.main_rb_classify:
                main_rb_classify.setChecked(true);
                break;
            case R.id.main_rb_community:
                main_rb_community.setChecked(true);
                break;
            case R.id.main_rb_shopping:
                main_rb_shopping.setChecked(true);
                break;
            case R.id.main_rb_user:
                main_rb_user.setChecked(true);
                break;
        }

    }
}
